
        <div class="x-body">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label for="level-id" class="layui-form-label">
                        id
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="level-id" name="id" disabled="" value="<?php echo $data['id'] ?>" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="level-name" class="layui-form-label">
                        <span class="x-red">*</span>权限规则
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="level-name" name="name" required="" lay-verify="required" autocomplete="off" value="<?php echo $data['name'] ?>" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="level-name" class="layui-form-label">
                        <span class="x-red">*</span>权限名字
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="name" name="title" required="" lay-verify="required" autocomplete="off" value="<?php echo $data['title'] ?>" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="level-kiss" class="layui-form-label">
                        <span class="x-red">*</span>所属分类
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="level-kiss" name="cname" required="" value="<?php echo $data['cname'] ?>" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label">
                    </label>
                    <button class="layui-btn" lay-filter="save" lay-submit="">
                        保存
                    </button>
                </div>
            </form>
        </div>
        <script>
            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;
            
              //监听提交
              form.on('submit(save)', function(data){
                console.log(data);
                //发异步，把数据提交给php
                $.ajax({
                    url: '{:U('admin/rbac/rbac_edit')}',
                    type: 'POST',
                    dataType: 'json',
                    data: data.field,
                })
                .done(function(res) {
                   if (res.error==1) {
                        layer.msg(res.info,{icon:1});
                    }else{
                        layer.alert("修改成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.location.reload();
                        });                        
                    };
                })
                return false;
              });
              
              
            });
        </script>
